
//请求根路径

let baseURL ='https://api.tushuxia.com'//注意这是线上数据

function request(url,data={}, method='GET'){
  return new Promise((resolve, reject) => {
    wx.request({
      url: baseURL + url,
      data,
      method,
      // header: {
      //   cookie: wx.getStorageSync('cookies')?wx.getStorageSync('cookies').find(item => item.indexOf('MUSIC_U') !== -1):''
      // },
      header: {
        'content-type': 'application/json' // 默认值
      },
      success: (res) => {
        resolve(res.data); // resolve修改promise的状态为成功状态resolved
      },
      fail: (err) => {
        // console.log('请求失败: ', err);
        reject(err); // reject修改promise的状态为失败状态 rejected
      }
    })
  })
}

//导出request
export default request
